<template>
	<view>
		<!-- 导航栏 -->
		<cu-custom bgColor="bg-white" class="nav-bar" :isBack="true">
			<block slot="content">联盟</block>
		</cu-custom>
		<view class="content">
			<view class="moneyHead">
				<view class="moneyHeadTop">
					<view class="moneyText">
						150
					</view>
					<view class="moneyTips">
						联盟总人数
					</view>
				</view>
				<view class="monehHeadBottom">
					<view class="moneyInfoView">
						<view class="moneyInfoItem">
							<view class="test">1元</view>
							<view class="tips">总算力(联盟)</view>
						</view>
						<view class="moneyInfoItem">
							<view class="text">1元</view>
							<view class="tips">总人数(直推)</view>
						</view>
						<view class="moneyInfoItem">
							<view class="test">1元</view>
							<view class="tips">总算力(直推)</view>
						</view>
					</view>
					<view class="botRow" >
						<navigator url="/pages/user/recharge">
							<view class="btn-cz">邀请好友</view>
						</navigator>
					</view>
				</view>
			</view>
		
			
			<view class="list-head">			
				<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" style-type="text" active-color="#36d6be"></uni-segmented-control>
			</view>
			<view class="cate-content">
				<view v-show="current === 0">
					<scroll-view scroll-y="true" class="scroll-Y"  @scrolltolower="scrollToLower" :style="scrollH">
					<view class="money-list white" v-for="(item,index) in 3" :key="index">
						<view class="li">
							<view class="left">
								<view class="title">123</view>
								<view class="time">321</view>
							</view>
							<view class="right">
								<view class="number">
									123123元
								</view>
							</view>
						</view>
					</view>
					</scroll-view>
				</view>
				
				<view v-show="current === 1">
					<scroll-view scroll-y="true" class="scroll-Y"  @scrolltolower="scrollToLower" :style="scrollH">
					<view class="money-list white"  v-for="(item,index) in 3" :key="index">
						<view class="li">
							<view class="left">
								<view class="title">22222</view>
								<view class="time">222222222233333333</view>
							</view>
							<view class="right">
								<view class="number">
									123456789元
								</view>
							</view>
						</view>
					</view>
					</scroll-view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniSegmentedControl from "../../components/uni-segmented-control/uni-segmented-control.vue"
	
    export default {
		components: {uniSegmentedControl},
        computed: {
			scrollH:function(){
				let sys = uni.getSystemInfoSync();
				let winHeight = sys.windowHeight;
				return 'height:' + (winHeight - 220 - 70 - 44) + 'px;'
			}
        },
		data() {
		    return {
				items: ['已实名','未实名'],
				current: 0,//顶部栏目index
				user:{},
				allList:[
					{
						list:[],
						page:0,
						hasMore:true
					},
					{
						list:[],
						page:0,
						hasMore:true
					}
				],
				is_examine:0,//uni.getStorageSync('is_examine')
		    }
		},
		onLoad(options) {
			this.getRecharge(this.current)
		},
		onShow(){
			this.getUserInfo()
		},
        methods: {
			onClickItem(index) {
				if (this.current !== index) {
					this.current = index
					this.getRecharge(this.current)
				}
			},//顶级栏目
			getUserInfo(){
				this.$http
					.get('corps_info', {})
					.then((response) => {
						this.user = response.data.data
						// console.log(this.user)
						// console.log(response.data.data.is_examine)
						if(response.data.data.is_examine){
							uni.setStorageSync("is_examine",response.data.data.is_examine)
							this.is_examine = parseInt(response.data.data.is_examine)
						}
					})
					.catch((response) => {
						
					})
			},
			scrollToLower(){
				this.getRecharge(this.current)
			},
			getRecharge(index){
				let obj = this.allList[index]
				if(obj.hasMore){
					this.$http
						.get('get_recharge', {type:index,page:obj.page})
						.then((response) => {
							console.log(response)
							let _list = response.data.data
							let list = obj.list
							let newlist = list.concat(_list);
							this.allList[index].list = newlist
							this.allList[index].page ++
							
							if(_list.length == 0)
								this.allList[index].hasMore = false
								
						})
						.catch((response) => {
							
						})
				}
			}
			
		}
    }
</script>

<style>
	@import url("../../static/style/common.css");
	.moneyHead{
		width: 100%;
		height: 220px;
		position: relative;
		background: #38d6bf;
	}
	.moneyHeadTop{
		width:100%;
		height: 60px;
		color:#FFFFFF;
		text-align: center;
	}
	.moneyText{
		font-size: 50px;
		line-height: 80px;
	}
	.moneyTips{
		font-size: 16px;
		line-height: 20px;
		color: #EEE;
	}
	.monehHeadBottom{
		position: absolute;
		bottom: -60px;
		width:90%;
		left:5%;
		background: #FFF;
		border-radius: 5px;
	}
	.moneyInfoView{
		padding:20px 0 10px;
	}
	.moneyInfoView .moneyInfoItem{
		display: inline-block;
		width: 33.33%;
		text-align: center;
		line-height: 25px;
	}
	/* .moneyInfoItem .text{
		width: 100%;
		line-height: 30px;
	}
	.moneyInfoItem .tips{
		width: 100%;
		line-height: 30px;
	} */
	.botRow{
		margin: 10px 0;
		text-align: center;
	}
	.btn-cz{
		padding: 8px 10px;
		background: #38d6bf;
		border-radius: 20px;
		line-height: 20px;
		color: #FFF;
		width: 100px;
		margin: 0 auto;
	}
	
	.list-head{
		width:100%;
		line-height: 40px;
		border-bottom: 1px solid #CCC;
		margin-top: 70px;
	}
	
</style>
